/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package gestion;

import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;


import java.util.logging.Level;
import java.util.logging.Logger;
import negocio.prestamo;
import operacionesDB.AbstractDB;

/**
 *
 * @author Luis Felipe Gomez
 */
public class DBgestionPrestamo extends AbstractDB {

    private ResultSet rs;
    private PreparedStatement r;

    public void buscarPrestamoDB() {
        rs = null;
        r = null;


    }

    public ResultSet todosPrestamos() {
        try {
            r = (PreparedStatement) this.con.prepareStatement(" call todosPrestamo");

            rs = r.executeQuery();


        } catch (SQLException ex) {
            Logger.getLogger(DBgestionPrestamo.class.getName()).log(Level.SEVERE, null, ex);
        }
        return rs;

    }

    public ResultSet buscarPrestamo(int sbnBuscar, String a) {
        try {
            r = (PreparedStatement) this.con.prepareStatement("call consultarPrestamo (? , ?)");

            r.setInt(1, sbnBuscar);
            r.setString(2, a);
            rs = r.executeQuery();



        } catch (SQLException ex) {
            Logger.getLogger(DBgestionPrestamo.class.getName()).log(Level.SEVERE, null, ex);
        }



        return rs;
    }

    public void NuevoPrestamo(prestamo pres ) {
        try {
            r = (PreparedStatement) this.con.prepareStatement("call nuevoPrestamo (? , ? , ? , ? )");
            r.setString(1, pres.getFechaPrestamo()); 
            r.setString(2,pres.getFechaDevolucion());
            r.setInt(3, pres.getIdUsuario());
            r.setInt(4, pres.getIsbn());
            r.execute();
        } catch (SQLException ex) {
            Logger.getLogger(DBgestionPrestamo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
}
